package com.pos.app.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import com.pos.app.POSApplication;
import com.pos.app.R;
import com.pos.app.activity.base.ActivitySupport;
import com.pos.app.util.MyLogger;
import com.pos.app.util.cache.MyFileCache;
import com.pos.app.util.cache.MyFileCache.MyCacheParams;
import com.pos.app.util.log.PrintToFileLogger;

/**
 * @Title: 用户其启动界面
 * @Description: 用户其启动界面时候的一个启动页面完成一些初始化工作
 * 
 */
public class SplashActivity extends ActivitySupport
{

	private static final String SYSTEMCACHE = "pos";
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		POSApplication application = (POSApplication) getApplication();
		// 配置系统的缓存,可以选择性的配置
		MyCacheParams cacheParams = new MyCacheParams(this, SYSTEMCACHE);
		MyFileCache fileCache = new MyFileCache(cacheParams);
		application.setFileCache(fileCache);
		
		final View view = View.inflate(this, R.layout.splash, null);
		setContentView(view);
		// 渐变展示启动屏
		AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f);
		aa.setDuration(5000);
		view.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener()
		{
			@Override
			public void onAnimationEnd(Animation arg0)
			{
				startActivity(new Intent(context, LoginActivity.class));
				finish();
			}

			@Override
			public void onAnimationRepeat(Animation animation)
			{
			}

			@Override
			public void onAnimationStart(Animation animation)
			{
			}
		});
	}
	
	@Override
	protected void onResume()
	{
		super.onResume();
		// 校验SD卡
		checkMemoryCard();
		// 检测网络和版本
		validateInternet();
	}
}
